const express = require("express");
const router = express.Router();
// 系统配置文件
const Config = require("../../../config");
const userModule = require("../../../api/user/user");
const ManageModule = require("../../../api/mange/manage");
// 我的设备列表
router.get("/GetDeviceList", (req, res) => { });
// 删除设备
router.post("/DeleteDevice", (req, res) => { });
// 频道帖子列表
router.get("/GetChannelDynamicList", () => { });
// 发布动态
router.post("/PublishDynamic", (req, res) => {
  userModule.PublishDynamic(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 收藏动态
router.post("/CollectDynamic", (req, res) => {
  userModule.CollectDynamic(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 动态信息
router.get("/dynamicInfo", (req, res) => {
  userModule.DynamicInfo(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 动态点赞列表
router.get("/dynamicFoverList", (req, res) => {
  userModule.DynamicFoverList(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 动态评论列表
router.get("/dynamicCommentList", (req, res) => {
  userModule.DynamicCommentList(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 动态评论回复列表
router.get("/GetDynamicCommentReplyList", (req, res) => {
  userModule.DynamicCommentReplyList(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 获取动态列表
router.get("/dynamicList", (req, res) => {
  userModule.GetDynamicList(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 删除动态
router.post("/DeleteDynamic", (req, res) => {
  userModule.DeleteDynamic(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 修改动态
router.post("/updateDynamic", (req, res) => {
  userModule.updateDynamic(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 点赞
router.post("/FoverDynamic", (req, res) => {
  userModule.FoverDynamic(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 评论
router.post("/CommentDynamic", (req, res) => {
  userModule.CommentDynamic(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 设置邀请人
router.post("/inviteSet", (req, res) => { });
// 下线列表
router.get("/inviteList", (req, res) => { });
// 删除用户
router.post("/remove", (req, res) => {
  let user = req.$user;
  removeModule({ id: user }).then(res.send, res.send);
});
// 用户详细信息
router.get("/info", (req, res) => {
  userModule.GetInfo(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 更新用户信息（前端版，不允许修改敏感信息）
router.post("/update", (req, res) => {
  userModule.UpdateInfo(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});

router.get("/NavieAdminRouterList", (req, res) => {
  userModule.NavieAdminRouterList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
})


// 用户登录
router.post("/login", (req, res) => {
  userModule.Login(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// token 验证
router.post("/tokenCheck", (req, res) => {
  userModule.CheckToken(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 用户注册
router.post("/register", (req, res) => {
  registerModule(req.body).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 修改资料（头像）
router.post("/changeAvatar", (req, res) => {
  let { avatar } = req.body;
  href = new URL(avatar);
  avatar = href.href;
  let user = req.$user;
  updateModule(user, { avatar }).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 修改资料（出生日期）
router.post("/changeBirth", (req, res) => {
  let user = req.$user;
  let { birth } = req.body;
  let [birth_year, birth_month, birth_day] = birth.split("-");
  updateModule(user, { birth_year, birth_month, birth_day }).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 修改密码
router.post("/changePassword", (req, res) => {
  changePasswordModule(req.body).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 获取注销状态
router.get("/GetErase", (req, res) => {
  userModule.GetErase(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 注销
router.post("/logoff", (req, res) => {
  userModule.Erase(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 取消注销
router.post("/cancelLogoff", (req, res) => {
  userModule.CancelErase(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 退出登录
router.post("/loginout", (req, res) => {
  userModule.loginout(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 绑定手机
router.post("/bindMobile", (req, res) => {
  res.send({ code: 0, msg: "操作成功" });
});
// 解绑微信
router.post("/unbindWechat", (req, res) => {
  let user = req.$user;
  res.send({ code: 0, msg: "操作成功" });
});
// 绑定微信
router.post("/bindWechat", (req, res) => {
  let user = req.$user;
  let { openid } = req.body;
  res.send({ code: 0, msg: "操作成功" });
});
// 清空收货地址
router.post("/EmptyAddress", (req, res) => {
  userModule.EmptyAddress(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取收货地址
router.get("/getAddressList", (req, res) => {
  userModule.AddressList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 添加收货地址
router.post("/addAddress", (req, res) => {
  userModule.AddAddress(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 设置默认地址
router.post("/SetDefaultAddress", (req, res) => {
  userModule.SetDefaultAddress(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 更新收货地址
router.post("/updateAddress", (req, res) => {
  userModule.UpdateAddress(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 删除收货地址
router.post("/deleteAddress", (req, res) => {
  userModule.deleteAddress(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取消息列表
router.get("/GetconversationList", (req, res) => { });
// 阅读消息
router.get("/LookConversation", (req, res) => { });
// 删除会话
router.get("/DeleteConversation", (req, res) => { });
// 发送即时消息
router.post("/SendMessage", (req, res) => {
  userModule.SendMessage(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取聊天记录
router.get("/GetMessageHistory", (req, res) => {
  userModule.GetMessageHistory(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取消息列表
router.get("/GetMessageList", (req, res) => {
  userModule.GetMessageList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取通知列表
router.get("/GetNoticeMessageList", (req, res) => {
  userModule.GetNoticeMessageList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取通讯录列表
router.get("/GetMailList", (req, res) => {
  userModule.GetMailList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 创建群聊
router.post("/createdGroup", (req, res) => {
  userModule.CreatedGroup(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 解散群聊
router.post("/DisbandGroup", (req, res) => {
  userModule.DisbandGroup(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 群聊踢出成员
router.post("/KickMember", (req, res) => {
  userModule.KickMember(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取App管理系统路由列表
router.get("/GetAppAdminRouterList", (req, res) => {
  userModule.GetAppAdminRouterList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取管理系统路由列表
router.get("/GetAdminRouterList", (req, res) => {
  userModule.GetAdminRouterList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取管理系统个性化配置对象
router.get("/GetAdminCustomize", (req, res) => {
  userModule.GetAdminCustomize(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 更新管理系统个性化配置对象
router.get("/UpdateAdminCustomize", (req, res) => {
  userModule.UpdateAdminCustomize(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 获取漂流瓶
router.get("/GetDrift", (req, res) => {
  userModule.GetDrift(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 写漂流瓶
router.post("/WriteDrift", (req, res) => {
  userModule.WriteDrift(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 丢弃漂流瓶
router.get("/DiscardDrift", (req, res) => {
  userModule.DiscardDrift(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
// 添加位置
router.post("/AddLocation", (req, res) => {
  userModule.PushMyLocation(req).then(
    (r) => {
      res.send(r);
    },
    (e) => res.send(e)
  );
});
// 获取附近列表
router.get("/GetNearbyList", (req, res) => {
  ManageModule.userList(req).then(
    (r) => res.send(r),
    (e) => res.send(e)
  );
});
module.exports = router;
